home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_kdelibs.idb / usr / freeware / kde / include / kfontdialog.h.z / kfontdialog.h
Encoding:
C/C++ Source or Header  |  1999-01-26  |  6.8 KB  |  236 lines

  1. /*
  2.     $Id: kfontdialog.h,v 1.11 1998/06/01 09:13:35 kalle Exp $
  3.  
  4.     Requires the Qt widget libraries, available at no cost at 
  5.     http://www.troll.no
  6.        
  7.     Copyright (C) 1997 Bernd Johannes Wuebben   
  8.                        wuebben@math.cornell.edu
  9.  
  10.     This program is free software; you can redistribute it and/or modify
  11.     it under the terms of the GNU Library General Public License as
  12.     published by  
  13.     the Free Software Foundation; either version 2 of the License, or
  14.     (at your option) any later version.
  15.  
  16.     This program is distributed in the hope that it will be useful,
  17.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  18.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  19.     GNU General Public License for more details.
  20.  
  21.     You should have received a copy of the GNU Library General Public License
  22.     along with this program; if not, write to the Free Software
  23.     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  24.   
  25.     $Log: kfontdialog.h,v $
  26.     Revision 1.11  1998/06/01 09:13:35  kalle
  27.     Added static getFontAndText()
  28.  
  29.     Revision 1.10  1998/06/01 08:42:42  kalle
  30.     KFontDialog:
  31.     - you can now enter your own example string
  32.     - new static method getXLFD() that converts a QFont() to a X Logical Font Description
  33.  
  34.     KIntegerLine:
  35.     - new signal valueChanged( int )
  36.  
  37.     Revision 1.9  1998/01/21 15:07:00  jacek
  38.     Added real KCharsets support
  39.  
  40.     Revision 1.7  1997/11/09 22:56:12  wuebben
  41.     Bernd: colorscheme related changes
  42.  
  43.     Revision 1.6  1997/11/09 03:45:57  wuebben
  44.     *** empty log message ***
  45.  
  46.     Revision 1.5  1997/10/21 20:45:01  kulow
  47.     removed all NULLs and replaced it with 0L or "".
  48.     There are some left in mediatool, but this is not C++
  49.  
  50.     Revision 1.4  1997/10/16 11:15:22  torben
  51.     Kalle: Copyright headers
  52.     kdoctoolbar removed
  53.  
  54.     Revision 1.3  1997/10/05 18:25:55  ssk
  55.     Added short descriptions for documentation index.
  56.  
  57.     Revision 1.2  1997/05/02 16:46:39  kalle
  58.     Kalle: You may now override how KApplication reacts to external changes
  59.     KButton uses the widget default palette
  60.     new kfontdialog version 0,5
  61.     new kpanner by Paul Kendall
  62.     new: KIconLoader
  63.  
  64.     Revision 1.6  1997/04/29 03:11:18  wuebben
  65.     Added more comments
  66.  
  67.     Revision 1.5  1997/04/29 02:44:24  wuebben
  68.  
  69.     added support for ~/.kde/config/kdefonts
  70.     and X server fontlist lookup
  71.  
  72.     Revision 1.4  1997/04/27 01:50:49  wuebben
  73.  
  74.     Revision 1.3  1997/04/20 14:59:45  wuebben
  75.     fixed a minor bug which caused the last font in the font list to not
  76.     be displayed
  77.  
  78.     Revision 1.1  1997/04/20 00:18:15  wuebben
  79.     Initial revision
  80.  
  81.     Revision 1.2  1997/03/02 22:40:59  wuebben
  82.  
  83.     Revision 1.1  1997/01/04 17:36:44  wuebben
  84.     Initial revision
  85.  
  86.  
  87. */
  88.  
  89.  
  90. #ifndef _K_FONT_DIALOG_H_
  91. #define _K_FONT_DIALOG_H_
  92.  
  93. #include <qmsgbox.h>
  94. #include <qpixmap.h>
  95. #include <qapp.h>
  96. #include <qframe.h> 
  97. #include <qbttngrp.h>
  98. #include <qchkbox.h>
  99. #include <qcombo.h>
  100. #include <qframe.h>
  101. #include <qgrpbox.h>
  102. #include <qlabel.h>
  103. #include <qlined.h>
  104. #include <qlistbox.h>
  105. #include <qpushbt.h>
  106. #include <qradiobt.h>
  107. #include <qscrbar.h>
  108. #include <qtooltip.h>
  109.  
  110. #include <qstring.h>
  111. #include <qfont.h>
  112.  
  113. /**
  114. * Dialog for interactive font selection.
  115. * @author Bernd Wuebben (wuebben@kde.org)
  116. * @version $Id: kfontdialog.h,v 1.11 1998/06/01 09:13:35 kalle Exp $
  117. */
  118. class KFontDialog : public QDialog {
  119.  
  120.     Q_OBJECT
  121.  
  122.       // Usage of the KFontDialog Class:
  123.       //
  124.       // Case 1) The pointer fontlist is null ( Recommended Usage !!)
  125.       // 
  126.       // In this case KFontDialog will first search
  127.       // for ~/.kde/config/kdefonts. If kdefonts if available
  128.       // it will insert the fonts listed there into the family combo.
  129.       // 
  130.       // Note: ~/.kde/config/kdefonts is managed by kfontmanager. 
  131.       // ~/.kde/config/kdefonts is a newline separated list of font names.
  132.       // Such as: time\nhelvetica\nfixed\n etc.You should however not 
  133.       // manipulate that list -- that is the job of kfontmanager.
  134.       // 
  135.       // If ~/.kde/config/kdefonts doesn't exist, KFontDialog will query
  136.       // the X server and insert all availabe fonts.
  137.       //
  138.       // Case 2) The pointer fontlist is non null. In this cae KFontDialog 
  139.       // will insert the strings of that QStrList into the family combo.
  140.       // 
  141.       // Note: Due to a bug in Qt 1.2 you must 
  142.       // supply at this point at least two fonts in the QStrList that
  143.       // fontlist points to. The bug has been reported and will hopefully
  144.       // be fixed in Qt.1.3. 
  145.  
  146.  
  147. public:
  148.     KFontDialog( QWidget *parent = 0L, const char *name = 0L,
  149.             bool modal = FALSE, const QStrList* fontlist = 0L );
  150.  
  151.     void setFont( const QFont &font );
  152.     QFont font()    {  return selFont; }
  153.  
  154.     /*
  155.      * This is probably the function you are looking for.
  156.      * Just call this to pop up a dialog to get the selected font.
  157.      * returns result().
  158.      */
  159.  
  160.     static int getFont( QFont &theFont );
  161.  
  162.   /*
  163.    * When you are not only interested in the font selected, but also
  164.    * in the example string typed in, you can call this method.
  165.    */
  166.   static int getFontAndText( QFont &theFont, QString &theString );
  167.  
  168.   /*
  169.    * This function converts a QFont into the corresponding X Logical Font 
  170.    * Description.
  171.    */
  172.   static QString getXLFD( const QFont &theFont );
  173.  
  174. signals:
  175.     /*
  176.      * connect to this to monitor the font as it as selected if you are
  177.      * not running modal.
  178.      */
  179.     void fontSelected( const QFont &font );
  180.  
  181. private slots:
  182.  
  183.       void     family_chosen_slot(const char* );
  184.       void      size_chosen_slot(const char* );
  185.       void      weight_chosen_slot(const char*);
  186.       void      style_chosen_slot(const char*);
  187.       void      display_example(const QFont &font);
  188.       void      charset_chosen_slot(const char *);
  189.       void      setColors();
  190. private:
  191.  
  192.     bool loadKDEInstalledFonts();
  193.     void fill_family_combo();
  194.     void setCombos();
  195.    
  196.     QGroupBox     *box1;
  197.     QGroupBox     *box2;
  198.     
  199.     // pointer to an optinally supplied list of fonts to 
  200.     // inserted into the fontdialog font-family combo-box
  201.     QStrList     *fontlist; 
  202.  
  203.     QLabel     *family_label;
  204.     QLabel     *size_label;
  205.     QLabel       *weight_label;
  206.     QLabel       *style_label;
  207.     QLabel     *charset_label;
  208.  
  209.     QLabel     *actual_family_label;
  210.     QLabel     *actual_size_label;
  211.     QLabel       *actual_weight_label;
  212.     QLabel       *actual_style_label;
  213.     QLabel     *actual_charset_label;
  214.  
  215.  
  216.     QLabel     *actual_family_label_data;
  217.     QLabel     *actual_size_label_data;
  218.     QLabel       *actual_weight_label_data;
  219.     QLabel       *actual_style_label_data;
  220.     QLabel     *actual_charset_label_data;
  221.     QComboBox    *family_combo;
  222.     QComboBox    *size_combo;
  223.     QComboBox    *weight_combo;
  224.     QComboBox    *style_combo;
  225.     QComboBox     *charset_combo;    
  226.     QPushButton     *ok_button;
  227.     QPushButton     *cancel_button;
  228.  
  229.     QLineEdit       *example_edit;
  230.     QFont         selFont;
  231.  
  232. };
  233.  
  234.  
  235. #endif
  236.